# import logging
#
# logger = logging.getLogger('django')
import sys
import os
from loguru import logger as log_uru
from django.conf import settings

log_path = os.path.join(os.path.dirname(settings.BASE_DIR), 'logs', 'luffy.log')
log_uru.configure(handlers=[
    {
        "sink": sys.stderr,
        # 输出到命令行
        "format": "【<lvl>{level:8}</>】【{time:YYYY-MM-DD HH:mm:ss.SSS}】【{name}:{module}】【{line}】【<lvl>{message}</>】",
        "colorize": True
    },
    {
        "sink": log_path,
        # 输出到文件中
        "format": "【{level:8}】【{time:YYYY-MM-DD HH:mm:ss.SSS}】【{name}:{module}】【{line}】【{message}】",
        "colorize": False,
        # 设置超过 500 MB 新创建一个 log 文件
        'rotation': "500 MB",
        # 设置日志文件最多保留 10 个
        'retention': 10,
        # 进行文件压缩
        # 'compression': 'zip'
    },
])
